
// 数字划分：输入 1234987897 输出 1,234,987,897
function change(num) {
    // let res = []
    // for (let i in num) {
    //     console.log(i);
    //     console.log(num[i]);
    //     res.push(num[i])
    // }
    let ret = []
    let len = num.length
    console.log(len);
    let j = 0
    for (let i = len - 1; i >= 0; i--) {
        if (j == 3) {
            ret.unshift(",")
            i++
            j = 0
        } else {
            ret.unshift(num[i])
            console.log(ret);
            j++
        }
        // res[i]
    }
    // return 
    console.log(ret.join(""));
}
change("1234987897")